﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="lib/jquery-latest.js" type="text/javascript"></script>
    <script src="lib/jquery.xslt.js" type="text/javascript"></script>
    <script src="lib/jquery.tmpl.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        jQuery(function ($) {

            var successFunc = function (data, textStatus, jqXHR) {
                $("#output").append("Success <BR/>");
                $("#output").append("Authorization:" + jqXHR.getResponseHeader("Authorization") + "<BR />");
                $("#output").append("cofews_version:" + jqXHR.getResponseHeader("cofews_version") + "<BR />");
                $("#output").append("cofews_signature:" + jqXHR.getResponseHeader("cofews_signature") + "<BR />");
                $("#output").append("cofews_expireTime:" + jqXHR.getResponseHeader("cofews_expireTime") + "<BR />");
            };

            var errorFunc = function (data, textStatus, jqXHR) {
                document.write("Error <BR/>");
            };

            var callUrl = function (urlPath, data) {
                var params = {
                    type: "POST",
                    url: urlPath,
                    success: successFunc,
                    error: errorFunc
                };

                if (data != null && data != undefined)
                    params.data = data;

                $.ajax(params);
            };


            $("button#signin").click(function () {
                var crediential = $("#signin_form").serialize();
                //"username=Test&password=Test"
                console.log(crediential);
                callUrl("/users/signIn", crediential);
            });

            $("button#refresh").click(function () {
                callUrl("/users/signIn");
            });

            $("button#signout").click(function () {
                callUrl("/users/signOut");
            });
        });
     
    </script>
    <title></title>
</head>
<body>
    <form id="signin_form">
        <input type="text" name="username" value="Test" />
        <input type="text" name="password" value="Test" />
    </form>

   <button id="signin">SignIn</button>
   <button id="refresh">Refresh</button>
   <button id="signout">SignOut</button>
   <div id="output"></div>
</body>
</html>
